package base.util;

import base.standard.constant.message.MessageCode;
import base.standard.constant.message.MessageFace;
import base.standard.constant.message.StatusCode;
import base.bean.StandardResponse;

/**
 * Response util
 *
 * @description: 返回值工具
 * @author: cyj
 * @date 2020 -10-15 17:17:36
 */
public class ResponseUtil {

    public static <T> StandardResponse<T> success(T data, String message) {
        return new StandardResponse<T>(data);
    }

    public static <T> StandardResponse<T> success(T data) {
        return new StandardResponse<T>(data);
    }

    public static <T> StandardResponse<T> success(String message) {
        return new StandardResponse<T>(message);
    }

    public static <T> StandardResponse<T> success() {
        return new StandardResponse<T>();
    }

    public static <T> StandardResponse<T> success(MessageCode messageCode, boolean result) {
        String message = new MessageFace(messageCode, result ? StatusCode.SUCCESS : StatusCode.FAILED).message;
        return new StandardResponse<T>(message);
    }

}
